<template>

  <div class="table1_container">
    <div class="table1_dataShower" style="padding-bottom: 50px; padding-top: 50px; box-sizing: border-box">
      <button class="report-top-button" @click="back">返回上级页面</button>
      <div style="text-align: center; margin: 10px 0;">
        <div style="display: inline-flex; gap: 20px;">
          <!-- 未完成 -->
          <div style="display: flex; align-items: center;">
            <div
              style="width: 16px; height: 16px; background-color: #ffffff; border: 1px solid #ddd; margin-right: 5px;"
            />
            <span>未完成</span>
          </div>

          <!-- 已完成 -->
          <div style="display: flex; align-items: center;">
            <div
              style="width: 16px; height: 16px; background-color: #e6f7e6; border: 1px solid #ddd; margin-right: 5px;"
            />
            <span>已完成</span>
          </div>

          <!-- 不合格重采 -->
          <div style="display: flex; align-items: center;">
            <div
              style="width: 16px; height: 16px; background-color: #ffebeb; border: 1px solid #ddd; margin-right: 5px;"
            />
            <span>不合格重采</span>
          </div>
        </div>
      </div>
      <h1>{{ reportData.fenxiangName }}工程质量验收记录</h1>
      <span class="table1_reportId" style="text-align: right; display: block;margin-right:23%; margin-bottom: 5px;"> 编号： {{  }}</span>
      <table class="fenxiang-table1_top_table">
        <tr>
          <td colspan="3" style="font-weight: 700">单位（子单位）工程名称</td>
          <td colspan="5">{{ reportData.subprojectName }}</td>
          <td colspan="3" style="font-weight: 700">分部（子分部）工程名称</td>
          <td colspan="5">{{ reportData.fenbuProjectName }}</td>
        </tr>
        <tr>
          <td colspan="3" style="font-weight: 700">分项工程工程量</td>
          <td colspan="5">{{ reportData.area }}</td>
          <td colspan="3" style="font-weight: 700">检验批数量</td>
          <td colspan="5">{{ reportData.taskAmount }}</td>
        </tr>
        <tr>
          <td colspan="3" style="font-weight: 700">施工单位</td>
          <td colspan="4">{{ reportData.projectName }}</td>
          <td colspan="2" style="font-weight: 700">项目负责人</td>
          <td colspan="3">{{ reportData.shigongDirector }}</td>
          <td colspan="2" style="font-weight: 700">项目技术负责人</td>
          <td colspan="2">{{ reportData.technicalDirector }}</td>
        </tr>
        <tr>
          <td colspan="3" style="font-weight: 700">分包单位</td>
          <td colspan="4">{{ reportData.fenbaoData.fenbaoCompany }}</td>
          <td colspan="2" style="font-weight: 700">分包单位项目负责人</td>
          <td colspan="3">{{ reportData.fenbaoData.fenbaoDirector }}</td>
          <td colspan="2" style="font-weight: 700">分包单位技术负责人</td>
          <td colspan="2">{{ reportData.fenbaoData.fenbaoTechnical }}</td>
        </tr>
        <tr>
          <td style="font-weight: 700">序号</td>
          <td colspan="3" style="font-weight: 700">检验批名称</td>
          <td colspan="3" style="font-weight: 700">检验批容量</td>
          <td colspan="3" style="font-weight: 700">部位/区段</td>
          <td colspan="3" style="font-weight: 700">施工单位检查结果</td>
          <td colspan="3" style="font-weight: 700">监理单位验收结论</td>
        </tr>

        <!--TODO for循环=======================================================-->
        <tr v-for="(item, index) in reportData.data" :key="taskId">
          <td>{{ index + 1 }}</td>
          <td colspan="3">{{ item.inspectType }}</td>
          <td colspan="3">{{ item.inspectVolume }}</td>
          <td colspan="3">{{ item.inspectPart }}</td>
          <td colspan="3">{{ item.checkResult }}</td>
          <td colspan="3">{{ item.checkConclusion ? item.checkConclusion : '/' }}</td>
        </tr>
        <tr>
          <td style="height: 100px;text-align: left" colspan="16">
            <div style="margin-left: 2%; font-weight: 700">说明：</div>
          </td>
        </tr>
        <tr>
          <td rowspan="3" colspan="3" style="font-weight: 700">施工单位<br>检查结果</td>
          <td rowspan="3" colspan="7"></td>
          <td colspan="6" style="border-bottom-width: 0"/>
        </tr>
        <tr>
          <td colspan="6" style="border-top-width: 0;border-bottom-width: 0; font-weight: 700">项目专业技术负责人：{{
            }}
          </td>
        </tr>
        <tr>
          <td colspan="6" style="border-top-width: 0;text-align: right; letter-spacing: 1em"> 年 月 日</td>
        </tr>

        <tr>
          <td rowspan="3" colspan="3" style="font-weight: 700">监理单位<br> 验收结论</td>
          <td rowspan="3" colspan="7"></td>
          <td colspan="6" style="border-bottom-width: 0"/>
        </tr>
        <tr>
          <td colspan="6" style="border-top-width: 0;border-bottom-width: 0; font-weight: 700">专业监理工程师：{{ }}</td>
        </tr>
        <tr>
          <td colspan="6" style="border-top-width: 0;text-align: right; letter-spacing: 1em"> 年 月 日</td>
        </tr>
      </table>
    </div>
  </div>
</template>

<script>
import { searchFenxiangCheckPreview } from '@/api/statementManage/yanShou/statementManage'

/*
 *    这个报表真麻烦！！！
 *
 */

export default {
  data() {
    return {
      localStorageId: '',
      reportData: {},
      previewData: {},
      receivedData: {}
    }
  },
  async mounted() { // 钩子函数
    this.receivedData = JSON.parse(sessionStorage.getItem('tempObj'))
    console.log(this.receivedData)
    const { result } = await searchFenxiangCheckPreview(this.receivedData.subprojectId, this.receivedData.fenxiangId)
    this.reportData = result
    console.log(result)
  },
  beforeDestroy() { // 离开页面要做的事
    // 那就是清除localstorage！！！
    if (this.localStorageId) {
      localStorage.removeItem(this.localStorageId)
    }
    document.querySelector('body').setAttribute('style', 'background-color: white;') // 还原，因为这是个全局样式
  },
  beforeCreate() {
    document.querySelector('body').setAttribute('style', 'background-color:#f5f5f5;') // 设置对比色
  },
  methods: {
    back() {
      this.$router.go(-1)
    }
  }
}
</script>

<style>

/*
先来设置每个任务项对应的背景颜色吧！
 */
.row-unfinished {
  background-color: #ffffff; /* 未完成 - 白色或默认色 */
}

.row-finished {
  background-color: #e6f7e6; /* 已完成 - 浅绿色 */
}

.row-failed {
  background-color: #ffebeb; /* 不合格重采 - 浅红色 */
}

.table1_container {
  width: 70%;
  background: white;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  padding-bottom: 20px;
}

.table1_dataShower {
  width: 80%;
  background: white;
  margin: 0 auto;
  border: 2px black solid;
}

/*这是返回按钮的样式*/
.report-top-button {
  display: block;
  margin: 0 auto;
  margin-bottom: 20px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Arial', sans-serif;
  color: #ffffff;
  background: linear-gradient(90deg, #1e3a8a, #3b82f6); /* 建筑行业蓝色调，稳重且有活力 */
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.report-top-button:hover {
  background: linear-gradient(90deg, #1e3a8a, #2563eb);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.report-top-button:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
}

/*表格样式*/
.fenxiang-table1_top_table {
  width: 90%;
  margin: 0 auto;
  border-collapse: collapse;
  border: 1px solid black;
  table-layout: fixed;
}

/*表格的样式*/
.fenxiang-table1_top_table tr td {
  height: 70px;
  border: 1px solid black;
  word-wrap: break-word; /* 允许长单词换行 */
  overflow-wrap: break-word; /* 更现代的换行属性 */
}

#table1_top_table_last_col {
  width: 20%;
  min-height: 50px;
}

th {
  box-sizing: border-box !important;
}
</style>
